﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DiscoveryLogic.UI.Layouts.Controls
{
    public partial class LineGraphLine : UserControl
    {
        

        public LineGraphLine()
        {
            InitializeComponent();
        }

        public bool AlterTrack(double deltaX)
        {
            bool isValid = false;
            double newTrackRight = 0;
           
            Path track = EstimatedTrack;
            newTrackRight = (double)track.GetValue(Canvas.WidthProperty);
            newTrackRight += deltaX;
            //if (newTrackRight >= minimumPaymentLevel)
            //{

            if (newTrackRight >= 0)
            {
                track.SetValue(Canvas.WidthProperty, newTrackRight);
                isValid = true;
            }

            //}
            return isValid;
        }

        public bool SetTrack(double endPos){
            return SetTrack(endPos, false);
        }

        public bool SetTrack(double endPos, bool force)
        {
            bool isValid = false;
            double newTrackRight = 0;
            double minimumPaymentLevel = 0;
            Path track = EstimatedTrack;            
            
            newTrackRight = endPos - (double)Payments.GetValue(Canvas.WidthProperty);
            if (newTrackRight >= minimumPaymentLevel || force)
            {
                track.SetValue(Canvas.WidthProperty, newTrackRight);
                isValid = true;

            }
            return isValid;
        }

    }
}
